package com.shop.service.impl;

import com.shop.entity.LoginUser;
import com.shop.mapper.LoginUserMapper;
import com.shop.service.GeneralService;
import com.shop.service.LoginUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("loginUserService")
public class LoginUserServiceImpl implements LoginUserService {

    @Autowired
    LoginUserMapper loginUserMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public int add(LoginUser loginUser) throws Exception{
        int add =0;
        try {
            add=loginUserMapper.add(loginUser);
        } catch (Exception e) {
            throw new Exception("添加异常！");
        }

        return add;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public int update(LoginUser loginUser) throws Exception{
        int update=0;
        try {
            update = loginUserMapper.update(loginUser);
        } catch (Exception e) {
            throw new Exception("更新异常！");
        }
        return update;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public int del(LoginUser loginUser)throws  Exception {
        int del = 0;
        try {
            del=loginUserMapper.del(loginUser);
        } catch (Exception e) {
            throw new Exception("删除异常！");
        }
        return del;
    }

    @Override
    public LoginUser get(LoginUser loginUser) {
        return loginUserMapper.get(loginUser);
    }

    @Override
    public List<LoginUser> getList(LoginUser loginUser) {
        return loginUserMapper.getList(loginUser);
    }
}
